$(function() {

	var overviewData = null;
	var overviewind = [];
	

	$.ajax({
		url: severUrl+'index.php?m=Web&a=aboutUs_mobile',
		type: 'GET',
		dataType: 'JSONP'
	})
	.done(function(data) {
		console.log("success");
		console.log(data);

		overviewFun(data.overview);

		factsFun(data.facts);
		// businessFun(data.business);
		corporateFun(data.corporate);

	})
	.fail(function() {
		console.log("error");
	})
	.always(function() {
		console.log("complete");
	});



	function overviewFun(data){
		var Con = $('#yearListSwiperNav');

		var navCn = '';

		overviewData  =  data;

		for(var i in data){
			overviewind.push(i);
			 navCn += '<div class="swiper-slide" data-name="'+i+'">'+i+'</div>';
		}
		Con.html(navCn);

		function yearListSwiper(){
			 var yearListSwiper = new Swiper ('#yearListSwiper', {
	            freeMode:true,
	            slidesPerView : 'auto'

	        }) 
		}
		yearListSwiper();

		incidentCnFun(overviewind[0]);

		Con.find('.swiper-slide').eq(0).addClass('actcve');

		Con.on('click','.swiper-slide',function(){
			$(this).addClass('actcve').siblings().removeClass('actcve');

			incidentCnFun($(this).attr('data-name'));
		})






	}



	function incidentCnFun(year){

		var data = overviewData[year];

		var  incidentCn = $('#incidentCn');
		var  htmlN = '';

		for (var i = 0; i < data.length; i++) {
			htmlN += '<li class="clearfloat" data-year="'+data[i].title+'"><div class="text">'+data[i].description+'</div><div class="imgc"><img src="'+data[i].image_url+'"></div></li>';
		}
		incidentCn.html(htmlN);

	}





// facts
function factsFun(data){
	var FactsCon = $('#FactsCon');
	var html = '';

	var icon = ['&#xe637;','&#xe638;','&#xe647;','&#xe63a;']
	for (var i = 0; i < data.length; i++) {
		html += '<li><div class="iconC"><i class="iconfont">'+icon[i]+'</i></div><div class="nunber" id="ind-'+(i+1)+'">'+data[i].value+ifType(data[i].type)+'</div><p>'+data[i].title+'</p></li>';
	}

	FactsCon.html(html);

	// FactsFunXun(data)

	function ifType(type){
		if (type == "percent") {
			return '%';
		}else{
			return ' ';
		}
	}


}

// facts end



// corporateFun


function corporateFun(data){
	var ManagementList = $('#ManagementList');
	var html = '';

	for (var i = 0; i < data.length; i++) {
		html += '<li><a href="'+data[i].url+'"><div class="head">'+data[i].title+'</div><div class="imgc"><img src="'+data[i].image_url+'"></div></a></li>';
	}
	ManagementList.html(html);
}


// corporateFun end










})